﻿using UnityEngine;
using System.Collections;
using System;

public class Player : MonoBehaviour
{

    public UserData userData;
    public float speed = 10f;
    public GameObject bullet;
    public void Move(Vector3 dir)
    {
        transform.Translate(dir * speed * Time.deltaTime);
    }
    public void Rota(Vector3 rota)
    {
        transform.Rotate(rota);
    }

    public void Fire(double value)
    {
        if (value > 2.5)
        {
            value = 2.5;
        }
        GameObject pre = Resources.Load<GameObject>("Shell");
        GameObject go = Instantiate(pre);
        go.transform.position = transform.GetChild(2).transform.position;
        go.transform.rotation = transform.GetChild(2).transform.rotation;
        go.AddComponent<Rigidbody>();
        //go.GetComponent<Rigidbody>().AddForce(go.transform.forward * (float)value * 1000, ForceMode.Impulse);
        go.GetComponent<Rigidbody>().velocity = go.transform.forward * (float)value * 30;
    }
}


